Skip to content

Conversation

@graingert
Copy link
Contributor

@graingert graingert commented Sep 23, 2019

thankfully we now have black so multiline comprehensions are beautiful

@graingert
Copy link
Contributor Author

@adewes ^

@graingert
Copy link
Contributor Author

graingert commented Jan 29, 2020

perhaps a note to extract processing that requires multiple statements into a function:

Extract expressions that are too long or complicated to express directly within a list comprehension into a function:

def process(v):
    if v.ham == "spam":
        return 4
    if v.bacon == "eggs"
        return 7
    ...

def cond(v):
    ...

[process(x) for x in items if cond(v)]  # still preferable to map(process, filter(cond, items))

@adewes adewes merged commit 3d33a03 into quantifiedcode:master Feb 28, 2020
@graingert graingert deleted the patch-1 branch March 1, 2020 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants